package com.jerry.user.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jerry.common.service.BaseService;

import com.jerry.common.vo.PageModel;
import com.jerry.user.entity.User;
import com.jerry.user.mapper.UserMapper;
import com.jerry.token.model.TokenModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Filename:    UserService
 * Description:
 * Copyright:   Copyright (c)2016
 * Company:     lngtop
 *
 * @author: 谢余锋
 * @version: 1.0
 * Create at:   2016/7/8 11:16
 * <p/>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2016/7/8      谢余锋        1.0        1.0 Version
 */
@Service
@Transactional
public class UserService extends BaseService<User> {

    @Autowired
    private UserMapper userMapper;

    public User getById(String id) {
        return userMapper.selectUser(id);
        //return this.queryById(id);
    }

    public void saveUser(User user) {
        userMapper.insert(user);
    }

    public PageModel<User> getUserPage(int page, int pageSize) {
        return this.queryPageByWhere(page, pageSize, "id asc", null);
    }

    public User queryByUsername(String username) {
        return userMapper.queryByUsername(username);
    }
}
